#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#define MAXN 100005
using namespace std;

int n, x, a[MAXN], b[2*MAXN], s;
long long total;

int query(int p){
    int t = 0;
    for (int i=(p+MAXN);i;i-=(i&-i)){
        t += b[i];
    }
    return t;
}

void update(int p){
    for (int i=(p+MAXN);i < 2*MAXN; i+= (i&-i)){
        b[i]++;
    }
}

int main()
{
    freopen("median.txt","r", stdin);
    scanf("%d %d", &n, &x);
    for (int i=0;i<n;i++){
        scanf("%d", &a[i]);
        a[i] = a[i] >= x ? 1 : -1;
    }
    update(0);
    for (int i=0;i<n;i++){
        s += a[i];
        total += query(s);
        update(s);
    }
    printf("%lld\n", total);
    return 0;
}
